﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.Unity;
using Skynet.WebAdministracion.Views.ExamsMgm;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace Skynet.WebSite.Administracion
{
    public partial class ExamsMgmView : Infrastructure.Web.Views.Page, IExamsMgmView
    {


        private ExamsMgmPresenter _Presenter;
        [Dependency]
        public ExamsMgmPresenter Presenter
        {
            get { return _Presenter; }
            set
            {                 
                _Presenter = value;
                this._Presenter.View = this;
            }
        }
      
        protected void Page_Load(object sender, EventArgs e)
        {
            //ValidatorFactory valFactory = EnterpriseLibraryContainer.Current.GetInstance<ValidatorFactory>();
            //var test = valFactory.CreateValidator<BusinessEntities.Product>();
            this.odsExams.ObjectCreating += delegate(object ocds, ObjectDataSourceEventArgs args) { args.ObjectInstance = this.Presenter; };
            this.odsCategories.ObjectCreating += delegate(object ocds, ObjectDataSourceEventArgs args) { args.ObjectInstance = this.Presenter; };
            if (!Page.IsPostBack)
                this.Presenter.OnViewInitialized();
            else
            {
                if (ScriptManager.GetCurrent(this).IsInAsyncPostBack)
                {
 
                }
                this.Presenter.OnViewLoaded();  
            }
            
        }
        
      

        protected void ddlCategories_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

        protected void gvExams_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.gvExams.SelectedValue != null)
            {
                this.Presenter.SelectExam((Guid)this.gvExams.SelectedValue);
            }
            
        }
        public Guid CategoryId { get { return Guid.Parse(this.ddlCategories.SelectedValue); } }

        protected void lbNewExam_Click(object sender, EventArgs e)
        {
            this.Presenter.NewExam();
        }

        protected void odsExams_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
        {
            
        }








        public string SupportMessage
        {
            set { }
        }
    }
}